package com.hls.mybatis.util;

public class StringUtil {
    public static String columnToProperty(String column) 
    {
        
        if(column.equals(null)||column.equals(""))
            return "";
        
        Byte length = (byte) column.length();        
        StringBuilder sb = new StringBuilder(length);
        for (int i = 0; i < length; i++)              
        {
            if (column.charAt(i) == '_')              
            {
                while (column.charAt(i + 1) == '_')   
                {
                    i++;
                }
                sb.append(("" + column.charAt(++i)).toUpperCase());  
            } 
            else 
            {
                sb.append(column.charAt(i));
            }
        }
         return sb.toString();
     }
    
    /**
     * Capitalize first character
     * @param str
     * @return
     */
    public static String upperCaseFirstCharacter(String str)
    {
        StringBuilder strBuilder = new StringBuilder();
        char[] arr = str.toCharArray();
        for(int i=0;i<arr.length;i++)
        {
            if(i==0)
                strBuilder.append((arr[i]+"").toUpperCase());
            else strBuilder.append(arr[i]+"");                
        }
        return strBuilder.toString();
    }
}
